package NC;

public class NC62 {
    public boolean IsBalanced_Solution(TreeNode root) {
        if(root==null) return true;
        return Math.abs(dfs(root.left)-dfs(root.right))<=1&&IsBalanced_Solution(root.left)&&IsBalanced_Solution(root.right);
    }
    public int dfs(TreeNode root){
        if(root==null) return 0;
        return 1+Math.max(dfs(root.left),dfs(root.right));
    }
}

